package com.feng.gaoerfu.activity;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.feng.gaoerfu.R;
import com.feng.gaoerfu.base.BaseActivity;
import com.feng.gaoerfu.bean.BallPersonData;
import com.feng.gaoerfu.utils.T;

import butterknife.InjectView;
import butterknife.OnClick;

/**
 * @time 2017/9/8 0008 17:00
 */

public class AddFriendActivity extends BaseActivity {
    @InjectView(R.id.tv_back)
    TextView mTvBack;
    @InjectView(R.id.tv_title)
    TextView mTvTitle;
    @InjectView(R.id.iv_menu)
    ImageView mIvMenu;
    @InjectView(R.id.edt_nick_name)
    EditText mEdtNickName;
    @InjectView(R.id.edt_phone_num)
    EditText mEdtPhoneNum;
    @InjectView(R.id.tv_add)
    TextView mTvAdd;

    @Override
    public int initContentView() {
        return R.layout.activity_add_friend;
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {

    }


    @OnClick({R.id.tv_back, R.id.tv_add})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_back:
                finish();
                break;
            case R.id.tv_add:
                String name = mEdtNickName.getText().toString();
                add(name);
                break;
        }
    }

    private void add(String name) {

        if (TextUtils.isEmpty(name)) {
            T.showShort(mContext, "昵称不能为空!");
            return;
        }

        if (hasSamePerson(name)) {
            showShortToast("该球友已在列表中!");
            return;
        }
        Intent intent = new Intent();
        intent.putExtra("person", new BallPersonData(name));
        setResult(RESULT_OK, intent);
        finish();
    }
}
